package rabbitMQ.utils;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;

/**
 * @program: rabbitMQ
 * @description:
 * @author: hjk
 * @create: 2021-07-07 15:28
 **/
public class RabbitMqUtils {

    /**
     * 得到一个连接的 channel
     * @return
     * @throws Exception
     */
    public static Channel getChannel() throws Exception {
        //创建一个连接工厂
        ConnectionFactory factory = new ConnectionFactory();
        factory.setHost("134.175.245.21");
        factory.setUsername("guest");
        factory.setPassword("guest");
        Connection connection = factory.newConnection();
        Channel channel = connection.createChannel();
        return channel;
    }
}
